package com.dynamic.mybatis.core.intercept;

import java.util.HashSet;
import java.util.Set;

/**
 * @Description
 * @Author xs
 * @Date 2023/3/21 13:34
 */
public abstract class AbstractDynamicSqlSessionHandler<A, B, C, D> implements DynamicSqlSessionHandler<A, B, C, D> {
    private String namespace;
    private Set<String> mappedStatementIds = new HashSet<>();

    public AbstractDynamicSqlSessionHandler(String namespace) {
        this.namespace = namespace;
    }

    public AbstractDynamicSqlSessionHandler(Set<String> mappedStatementIds) {
        this.mappedStatementIds.addAll(mappedStatementIds);
    }

    /**
     * @param namespace         命名空间
     * @param mappedStatementId 长id(namespace+"."+shortId)
     */
    public AbstractDynamicSqlSessionHandler(String namespace, String mappedStatementId) {
        this.namespace = namespace;
        this.mappedStatementIds.add(mappedStatementId);
    }

    public String getNamespace() {
        return namespace;
    }

    public Set<String> getMappedStatementIds() {
        return mappedStatementIds;
    }
}